import React from 'react';
import ReactDom from 'react-dom';
import $ from 'webpack-zepto';
import AddressForm from './view/address-form.js';
import AddressList from './view/address-list.js';
import Util from '../common/util.js';



var type;
export default class Address extends React.Component {
    constructor(props) {
        super(props);
        type = Util.getUrlParam('type');
    };

    form() {
        return <AddressForm appId={this.props.appId}></AddressForm>;
    };

    list() {
        return <AddressList appId={this.props.appId}></AddressList>;
    };

    render() {

        var page = this.form();
        if ('list' == type ||!type) {
            page = this.list();
        }else if('form'==type){
            page = this.form();
        }
        return (
            <div>
                {page}
            </div>
        )
    };
};

ReactDom.render(
    <Address appId={Util.appId()}></Address>,
    $('#address')[0]
);
